/*
 * @Author: fisher
 * @Date: 2023-11-08 16:02:34
 * @LastEditTime: 2024-01-17 09:38:07
 * @LastEditors: fisher
 * @Description: cesium tools by fisher
 * @FilePath: \front-end-template\src\modules\DataManage\utils\FCT\index.js
 */
import Measure from "./measure/index.js";
export default class FTC {
  // 全局变量
  #viewer = undefined;
  #scene = undefined;
  #handler = undefined;
  #collection = undefined;
  constructor(viewer) {
    // 检查viewer对象
    if (!viewer) {
      throw new Error("请检查是否正确实例化viewer对象！");
    } else {
      this.#init(viewer);
    }
  }
  #init(viewer) {
    // 判断是否环境中引入Cesium
    if (!Cesium) {
      throw new Error("未检测到Ceisum对象！请正确引入Cesium");
    } else {
      // 初始化全局viewer
      this.#viewer = viewer;
      this.#scene = this.#viewer.scene;
      // 初始鼠标事件
      if (!this.#handler) {
        this.#handler = new Cesium.ScreenSpaceEventHandler(this.#scene.canvas);
      }
      // 初始化集合
      if (!this.#collection) {
        this.#collection = new Cesium.CustomDataSource("drawCollection");
      }
      this.#viewer.dataSources.add(this.#collection);
    }
  }
  // 注册静态子类
  static Measure = Measure;
}
